package org.bot.client.flow;

import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import org.bot.api.event.Events;
import org.bot.api.util.StringUtil;

/**
 * @author 沧月
 * @create 0015 2023/9/15 11:15
 * @description <流程执行器执行日志>
 */
public class FlowExecuteLog extends JSONObject {

    public FlowExecuteLog() {
        super.put("startTime", StringUtil.getTime());
    }

    public void putFlowName(String name) {
        super.put("flowName", name);
    }

    public void putEventData(Object data) {
        if (data == null) {
            super.put("eventData", null);
        } else {
            super.put("eventData", data.toString());
        }
    }

    public void putEvent(Events event) {
        super.put("event", event.getClass().getName());
    }

    public void putArg(String arg) {
        super.put("arg", arg);
    }

    public void putStatus(ExecuteStatus executeStatus) {
        super.put("status", executeStatus.getStatus());
    }

    public void putErrorMsg(String errorMsg) {
        super.put("errorMsg", errorMsg);
    }

    public void putEndTime() {
        super.put("endTime", StringUtil.getTime());
    }

    public void putBatchId(String batchId) {
        super.put("batchId", batchId);
    }

    public void putOrder(Integer order) {
        super.put("order", order);
    }

    public Integer getOrder() {
        return super.getInteger("order");
    }
}
